<template>
  <i :style="{ 'background-image': `url(${iconUrl})` }" class="icon" />
</template>

<script lang="ts" setup>
  const props = defineProps({
    name: {
      type: String,
      required: true,
    },
  });

  const iconUrl = computed(() => {
    return new URL(`/src/assets/icons/${props.name}.png`, import.meta.url).href;
  });
</script>

<style lang="less" scoped>
  .icon {
    display: inline-block;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    width: 24px;
    height: 24px;
    vertical-align: middle;
  }
</style>
